<template xmlns:v-clipboard="http://www.w3.org/1999/xhtml">
  <div>
    <div align="center">
      <el-card style="width: 700px" align="center">
        <el-row>
          <el-col :span="7">
            <el-input placeholder="请输入查询内容" v-model="username" clearable @clear="getUserMessage"></el-input>
          </el-col>
          <el-col  :span="1">
            <el-button type="primary" icon="el-icon-search" @click="getUserMessage">搜索</el-button>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="4"></el-col>
          <el-col>
            <el-table :data="userlist" border stripe style="width: 100%" align="center" height="700">
              <el-table-column prop="userid" v-if="show=false">              </el-table-column>
              <el-table-column prop="username" label="用户名" width="200%"></el-table-column>
              <el-table-column prop="upload" label="上传权限" width="100%">
                <template slot-scope="scope">
                  <el-switch v-model="scope.row.upload" @change="handleClick(scope.row.userid,scope.row.upload,scope.row.getfile,scope.row.city,scope.row.android)" type="primary"></el-switch>
                </template>
              </el-table-column>
              <el-table-column prop="getfile" label="读取权限" width="100%">
                <template slot-scope="scope">
                  <el-switch v-model="scope.row.getfile" @change="handleClick(scope.row.userid,scope.row.upload,scope.row.getfile,scope.row.city,scope.row.android)" type="primary"></el-switch>
                </template></el-table-column>
              <el-table-column prop="city" label="城市权限" width="100%">
                <template slot-scope="scope">
                  <el-switch v-model="scope.row.city" @change="handleClick(scope.row.userid,scope.row.upload,scope.row.getfile,scope.row.city,scope.row.android)" type="primary"></el-switch>
                </template></el-table-column>
              <el-table-column prop="android" label="平台权限" width="100%">
                <template slot-scope="scope">
                  <el-switch v-model="scope.row.android" @change="handleClick(scope.row.userid,scope.row.upload,scope.row.getfile,scope.row.city,scope.row.android)" type="primary"></el-switch>
                </template></el-table-column>
            </el-table>
          </el-col>
        </el-row>
      </el-card>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        quaryInfo:{
          quary:'',
          PageNum:1,
          PageSize:10
        },
        userlist:[],
        username:'',
        total:0,
      }
    },
    created(){
      this.getUserMessage()
    },
    methods:{
      async getUserMessage(){
        const {data:res}=await this.$http.post('mlusers/selectAll',{username:this.username})
        this.userlist = res
      },
      handleClick(id,upload,city,android,getfile){
          this.$http.post('mlusers/changePermission',{userid:id,upload:upload,city:city,android:android,getfile:getfile})
      }
    }
  }
</script>

